package com.av.rmi.sockets;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;

/**
 * Socket para el envio comprimido de datos
 * 
 * @author Victor J Morales R
 * 
 */
public class ZipSocket extends Socket {
	private InputStream in;
	private OutputStream out;

	public ZipSocket() {
		super();
	}// ZipSocket

	public ZipSocket(String host, int port) throws IOException {
		super(host, port);
	}// ZipSocket

	public InputStream getInputStream() throws IOException {
		if (in == null) {
			in = new GZIPInputStream(super.getInputStream());
		}
		return in;
	}// InputStream

	public OutputStream getOutputStream() throws IOException {
		if (out == null) {
			out = new GZIPOutputStream(super.getOutputStream());
		}
		return out;
	}// getOutputStream

	public synchronized void close() throws IOException {
		OutputStream o = getOutputStream();
		o.flush();
		super.close();
	}// close
}// ZipSocket